//
//  JLBaseViewController.swift
//  新浪微博
//
//  Created by linlin on 15/11/23.
//  Copyright © 2015年 jilin. All rights reserved.
//

import UIKit


class JLBaseViewController: UITableViewController {
    
    
    //用户是否登录
    var userLogin: Bool = JLUserAccount.userLogin
    

    override func viewDidLoad() {
        super.viewDidLoad()

        userLogin ? super.viewDidLoad() : setupVistorVidew()
    
        //用户登陆
        
    
    
    }

    //用户没有登陆显示访客视图
    func setupVistorVidew () {
        
        view = vistorView
        vistorView.delegate = self
        
        view.backgroundColor = UIColor(white: 235/225.0, alpha: 1);
//        view.backgroundColor = UIColor.grayColor()
        
        if self is JLHomeController {
            //首页动画
            vistorView.StartRotationView()
            
        }else if self is JLMessageController{
            vistorView.setupVistorViewInfo("visitordiscover_image_message", message: "登录后，别人评论你的微博，发给你的消息，都会在这里收到通知")
            
        }else if self is JLDiscoverController{
            vistorView.setupVistorViewInfo("visitordiscover_image_message", message: "登录后，最新、最热微博尽在掌握，不再会与实事潮流擦肩而过")
            
        }else if self is JLProfileController{
            vistorView.setupVistorViewInfo("visitordiscover_image_message", message: "登录后，你的微博、相册、个人资料会显示在这里，展示给别人")
        }
        
        
       //设置全局navgationItem
        navigationItem.leftBarButtonItem = UIBarButtonItem(title: "注册", style: UIBarButtonItemStyle.Plain, target: self, action: "VistorViewRegister");
         navigationItem.rightBarButtonItem = UIBarButtonItem(title: "登录", style: UIBarButtonItemStyle.Plain, target: self, action: "VistorViewLogin");
        
       
        
 
    }
    
    
    
    

    
    
    //懒加载
    lazy var vistorView: JLVistorView = {
        let view = JLVistorView()
        view.delegate = self
        return view
    }()
    
    
    
    
}

//实现代理方法
extension JLBaseViewController: JLVistorViewDelegate {
    func VistorViewLogin() {
        
        
        presentViewController(UINavigationController(rootViewController: JLOauthViewController()), animated: true, completion: nil)
        
        
        
    }
    
    func VistorViewRegister() {
        print("注册")
    }
    
}





